home *** CD-ROM | disk | FTP | other *** search
File List | 1992-06-24 | 6.6 KB | 231 lines |
- ' 6/24/92
- ' =================================================================
- ' DESCRIPTION:
- ' This GFA BASIC 3.x program demos and tests different screen text functions.
- ' Both native GFA BASIC commands (TEXT and PRINT) and calls to the VDI
- ' and GEMDOS are used.
- '
- ' The inspiration for this came from the horrible discovery that graphic text
- ' in HiSoft BASIC is MUCH faster than GFA BASIC's. TEXT is not a simple call
- ' to the ST's v_gtext funtion (VDISYS 8) but has been optimized to work quickly
- ' in the interpreter and across all text attributes. Unfortunately, TEXT
- ' works at the same speed when compiled as interpreted and is much slower
- ' than v_gtext (which is what HiSoft uses) with compiled programs using normal
- ' text. Also, it is not helped by screen accelerators like v_gtext
- ' (the blitter helps it quite a bit though).
- '
- ' CREDITS:
- ' It was written by Jonathan Corey and is in the Public Domain. Send any
- ' comments (or improvments to JWC-OEO on GEnie).
- '
- ' The original v_gtext routine is a slightly modified version of the one I
- ' found in the AccuSoft ST BASIC Programmer's Kit. It is faster than TEXT.
- '
- ' What's referred to here as mod #1 is a change to the above written by me.
- ' It is faster than TEXT and PRINT.
- '
- ' mod #2 is based on changes written by D.LIVINGST11 [Big Earnest] via GEnie.
- ' It is the fastest of the v_gtext implimentations here.
- '
- ' The routine for calling GEMDOS 9 came from D.SEBERG [IceBerg] via GEnie.
- ' This is an interesting one. It's does the fastest screen output with a
- ' screen accelerator (ST Turbo etc) installed and the slowest without one.
- '
- ' ======================================================================
- DEFWRD "a-z"
- DEFMOUSE 0
- DEFTEXT ,0,,, !0 is normal text, change to 1 for Bold etc..
- '
- PRINT CHR$(27)+"w"; !turn off line wrap
- '
- m$=" Speed test of screen output | methods using GFA BASIC 3.x|"
- m$=m$+" |Press a key after each screen"
- m$="[0]["+m$+"][Continue|Quit]"
- IF FORM_ALERT(1,m$)=2
- EDIT
- ENDIF
- m$="[2][|Set a clipping rectangle?][Full|Clip]"
- IF FORM_ALERT(1,m$)=2
- clip!=TRUE
- ENDIF
- '
- ~GRAF_HANDLE(char_w,char_h,box_w,box_h)
- '
- t$="All I want for breakfast, is my Two Front Teeth! For BREAKFAST you say?!?!"+CHR$(0)
- '
- screen_columns=(WORK_OUT(0)+1)\char_w
- IF screen_columns<LEN(t$) !for low res
- t$=LEFT$(t$,screen_columns-1)
- ENDIF
- '
- @tclip
- '
- ' ====================== GRAPHIC TEXT SECTION =========================
- CLS
- t_text$=" TEXT "
- t#=TIMER
- FOR line=1 TO 24
- TEXT 8,line*char_h,0,t$
- NEXT line
- t_text#=TIMER-t#
- CLIP OFF
- TEXT 8,char_h,SPACE$(screen_columns)
- TEXT 8,char_h,t_text$+"took "+STR$(t_text#/200)+" seconds."
- @tclip
- ~INP(2)
- '
- CLS
- t_vdisys1$=" VDISYS 8, orignl "
- len_t=LEN(t$)
- t#=TIMER
- FOR line=1 TO 24
- v_gtext_orig(8,line*char_h,t$)
- NEXT line
- t_vdisys1#=TIMER-t#
- CLIP OFF
- v_gtext_orig(8,char_h,SPACE$(screen_columns))
- v_gtext_orig(8,char_h,t_vdisys1$+"took "+STR$(t_vdisys1#/200)+" seconds.")
- @tclip
- ~INP(2)
- '
- CLS
- t_vdisys2$=" VDISYS 8, mod #1 "
- t#=TIMER
- FOR line=1 TO 24
- v_gtext_mod1(8,line*char_h,t$)
- NEXT line
- t_vdisys2#=TIMER-t#
- CLIP OFF
- v_gtext_mod1(8,char_h,SPACE$(screen_columns))
- v_gtext_mod1(8,char_h,t_vdisys2$+"took "+STR$(t_vdisys2#/200)+" seconds.")
- @tclip
- ~INP(2)
- '
- CLS
- t_vdisys3$=" VDISYS 8, mod #2 "
- t#=TIMER
- FOR line=1 TO 24
- v_gtext_mod2(8,line*char_h,t$)
- NEXT line
- t_vdisys3#=TIMER-t#
- CLIP OFF
- v_gtext_mod2(8,char_h,SPACE$(screen_columns))
- v_gtext_mod2(8,char_h,t_vdisys3$+"took "+STR$(t_vdisys3#/200)+" seconds.")
- @tclip
- ~INP(2)
- '
- ' ========================= CHARACTER TEXT SECTION ==============
- CLS
- t_print$=" PRINT "
- t#=TIMER
- FOR line=1 TO 24
- ' LOCATE 2,line
- ' PRINT t$;
- PRINT AT(2,line);t$
- NEXT line
- t_print#=TIMER-t#
- PRINT AT(1,1);SPACE$(screen_columns)
- PRINT AT(2,1);t_print$;"took ";t_print#/200;" seconds."
- ~INP(2)
- '
- CLS
- t_gemdos$=" GEMDOS 9 "
- t#=TIMER
- t$=t$+CHR$(0) !need to terminate strings with CHR$(0) for GEMDOS 9
- FOR line=1 TO 24
- LOCATE 2,line
- ~GEMDOS(9,L:V:t$)
- NEXT line
- t_gemdos#=TIMER-t#
- PRINT AT(1,1);SPACE$(screen_columns)
- PRINT AT(2,1);t_gemdos$;"took ";t_gemdos#/200;" seconds."
- ~INP(2)
- '
- ' ============================== SUMMARY ======================
- CLS
- PRINT " Ratios of elapsed time"
- PRINT
- PRINT " A TO B =2.0 means A takes twice as long as B (B is 2 times faster than A)"
- PRINT " A TO B =0.5 means A takes half as long as B (A is 2 times faster than B)"
- PRINT
- PRINT t_vdisys1$;" TO ";t_text$;"= ";ROUND(t_vdisys1#/t_text#,3)
- PRINT t_vdisys2$;" TO ";t_text$;"= ";ROUND(t_vdisys2#/t_text#,3)
- PRINT t_vdisys3$;" TO ";t_text$;"= ";ROUND(t_vdisys3#/t_text#,3)
- PRINT t_print$;SPC(11);" TO ";t_text$;"= ";ROUND(t_print#/t_text#,3)
- PRINT
- PRINT t_vdisys1$;" TO ";t_print$;"= ";ROUND(t_vdisys1#/t_print#,3)
- PRINT t_vdisys2$;" TO ";t_print$;"= ";ROUND(t_vdisys2#/t_print#,3)
- PRINT t_vdisys3$;" TO ";t_print$;"= ";ROUND(t_vdisys3#/t_print#,3)
- PRINT
- PRINT t_text$;SPC(11);" TO ";t_print$;"= ";ROUND(t_text#/t_print#,3)
- PRINT t_gemdos$;SPC(6);" TO ";t_print$;"= ";ROUND(t_gemdos#/t_print#,3)
- PRINT
- PRINT t_vdisys2$;" TO orig = ";ROUND(t_vdisys2#/t_vdisys1#,3)
- PRINT t_vdisys3$;" TO orig = ";ROUND(t_vdisys3#/t_vdisys1#,3)
- PRINT t_vdisys3$;" TO mod1 = ";ROUND(t_vdisys3#/t_vdisys2#,3)
- PRINT
- PRINT t_vdisys3$;" TO GMDOS9 = ";ROUND(t_vdisys3#/t_gemdos#,3)
- PRINT
- PRINT " End of test"
- ~INP(2)
- EDIT
- '
- > PROCEDURE v_gtext_orig(x_,y_,text_$)
- len_t=LEN(text_$)
- CONTRL(1)=1
- CONTRL(2)=0
- CONTRL(3)=len_t
- CONTRL(4)=0
- PTSIN(0)=x_
- PTSIN(1)=y_
- FOR column=0 TO len_t-1
- ' DPOKE INTIN+(2*column&),ASC(MID$(text_$,column&+1,1))
- WORD{INTIN+(2*column)}=ASC(MID$(text_$,column+1,1))
- ' CARD{INTIN... works too, all give the same results
- NEXT column
- VDISYS 8
- RETURN
- '
- > PROCEDURE v_gtext_mod1(x_,y_,text_$)
- len_t=LEN(text_$)
- CONTRL(1)=1
- CONTRL(2)=0
- CONTRL(3)=len_t
- CONTRL(4)=0
- PTSIN(0)=x_
- PTSIN(1)=y_
- FOR column_%=0 TO len_t-1
- ' DPOKE INTIN+(2*column_%),BYTE{(V:text_$)+column_%}
- WORD{INTIN+(2*column_%)}=BYTE{(V:text_$)+column_%}
- ' CARD{INTIN... works too, all give the same results
- NEXT column_%
- VDISYS 8
- RETURN
- '
- > PROCEDURE v_gtext_mod2(x_,y_,text_$)
- ' LOCAL p_str%,p_intin%,p_pin1%,chars_left
- ' globals are faster, locals are safer
- chars_left=LEN(text_$)
- CONTRL(1)=1
- CONTRL(2)=0
- CONTRL(3)=chars_left
- CONTRL(4)=0
- PTSIN(0)=x_
- PTSIN(1)=y_
- p_str%=V:text_$
- p_intin%=INTIN
- WHILE chars_left>0
- WORD{p_intin%}=BYTE{p_str%}
- INC p_str%
- ADD p_intin%,2
- DEC chars_left
- WEND
- VDISYS 8
- RETURN
- '
- > PROCEDURE tclip
- IF clip!
- CLIP (3*char_w)+3,(4*char_h)-4,WORK_OUT(0)-(9*char_w),WORK_OUT(1)-(7*char_h)
- ENDIF
- RETURN
-